package cn.anlab.anappframe.widget;

import cn.anlab.anappframe.R;
import android.app.AlertDialog;
import android.content.Context;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

/**
 * Loading进度框组件
 * 
 * @version 1.0
 * @author Stan Rong 2012-3-3
 */
public class CompProgressDialog {

	private Context context;
	private AlertDialog dialog;
	private ImageView ivLoading;
	
	public CompProgressDialog(Context context) {
		this.context = context;
		dialog = new AlertDialog.Builder(context).create();
		dialog.show();
		Window win = dialog.getWindow();
		win.setContentView(R.layout.comp_progress_dialog);
		dialog.dismiss();
		
		ivLoading = (ImageView)dialog.findViewById(R.id.comp_progress_dialog_loading);
		
		
	}
	
	/**
	 * 显示对话框
	 */
	public void show() {
		dialog.show();
		Animation anim = AnimationUtils.loadAnimation(context, R.anim.rotate_loading);
		ivLoading.startAnimation(anim);
	}
	
	/**
	 * 取消对话框
	 */
	public void dismiss() {
		dialog.dismiss();
		ivLoading.clearAnimation();
	}
	
	/**
	 * 判断是否正在显示
	 * @return
	 */
	public boolean isShowing() {
		return dialog.isShowing();
	}
	
}
